package io.ioscan.rzcoin.controller;

import io.ioscan.rzcoin.model.LoginForm;
import io.ioscan.rzcoin.model.LoginUser;
import io.ioscan.rzcoin.common.model.R;
import io.ioscan.rzcoin.service.LoginService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequiredArgsConstructor
@Api(tags = "登录的控制器")
public class LoginController {

    private final LoginService loginService;

    @PostMapping("/login")
    @ApiOperation(value = "会员的登录")
    @ApiImplicitParams({@ApiImplicitParam(name = "loginForm", value = "登录的表单参数")})
    public R<LoginUser> login(@RequestBody @Validated LoginForm loginForm) {
        LoginUser loginUser = loginService.login(loginForm);
        return R.ok(loginUser);
    }
}
